from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get('http://www.baidu.com')
result = WebDriverWait(driver, 5).until(EC.title_is('百度一下，你就知道'), message='标题不一致')

kw_element = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.ID, 'kw')))
print(kw_element.get_attribute('outerHTML'))

input_elements = WebDriverWait(driver, 5).until(EC.presence_of_all_elements_located([By.TAG_NAME, 'input']))
print(input_elements)
print(len(input_elements))

print(WebDriverWait(driver, 5).until(EC.text_to_be_present_in_element((By.LINK_TEXT, '新闻'), '新')))